import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yls.demoa.R;
import com.example.yls.demoa.Student;

import java.util.ArrayList;

/**
 * Created by yls on 2018/10/8.
 */

public class myadapter extends BaseAdapter{
            private Context context;
            private ArrayList<Student> studentArrayList;

      public myadapter(Context context,ArrayList<Student> studentArrayList){

         this.context=context;
         this.studentArrayList=studentArrayList;
      }
    @Override
    public int getCount() {
        return studentArrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return studentArrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);

         view=layoutInflater.inflate(R.layout.mylist,viewGroup,false);


        ImageView headView= view.findViewById(R.id.headimg);
        TextView namevView = view.findViewById(R.id.name);
        TextView ageView= view.findViewById(R.id.age);

         headView.setImageResource(studentArrayList.get(i).getImg());
         namevView.setText(studentArrayList.get(i).getName());



        return null;
    }
}
